<template>
  <div v-loading="loading" />
</template>
<script>
export default {
  data() {
    return {
      loading: true
    };
  },
  created() {
    if (this.$keycloak.authenticated) {
      this.saveUserInfo();
    }
  },
  methods: {
    saveUserInfo() {
      let user = {
        userId: null,
        userName: this.$keycloak.userName,
        nickName: null
      };
      this.$store.commit('UPDATE_USER', user);
      const auth = this.$store.state.auth;
      auth.isLoggedIn = true;
      auth.accessToken = this.$keycloak.token;
      auth.refreshToken = this.$keycloak.refreshToken;
      this.$store.commit('UPDATE_AUTH', auth);
      this.$router.push({ path: '/' });
    }
  }
};
</script>
